home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tosspd.zip / MSG.H < prev    next >
C/C++ Source or Header  |  1992-11-27  |  13KB  |  330 lines

  1. #include<io.h>
  2. #include<stdio.h>
  3. #include<conio.h>
  4. #include<stdarg.h>
  5. #include<stdlib.h>
  6. #include<alloc.h>
  7. #include<time.h>
  8. #include<string.h>
  9. #include<process.h>
  10.  
  11. #define byte unsigned char
  12. #define word unsigned int
  13. #define flag unsigned char
  14. #define TRUE    1
  15. #define FALSE   !TRUE
  16.  
  17. /*******************************************************************
  18.  These are structures for reading the RBBS records in binary format.
  19.  All RBBS records are set up in 128 byte blocks.
  20.  *******************************************************************/
  21. /*****************************************************************
  22.  This is the checkpoint Record. It is the first block of any
  23.  RBBS message file, ie; MAINM.DEF and contains vital pointer info.
  24.  *****************************************************************/
  25. struct checkpoint_record
  26.     {
  27.     char last_msg_num[8];                // ascii, leading space
  28.     word sec_lev_for_auto_add;              // integer value
  29.     char caller_number[10];                 // ascii, leading space
  30.     flag public_flag;                       // '/' = no PUB MSG's (17.4)
  31.     flag private_flag;                      // '/' = no PRV MGS's (17.4)
  32.     flag password_flag;                     // '/' = no PWD MSG's (17.4)
  33.     byte reserved1[33];                     // Zeroed
  34.     char user_count[5];                     // ascii, leading space
  35.     byte reserved2[6];                      // Zeroed
  36.     char msg_start_blk[7];                  // ascii, leading space
  37.     char next_msg_blk[7];               // ascii, leading space
  38. /************************************************************************
  39.  This is the number of the last block in the file when using fixed length
  40.  message base (does not grow). RBBS figures a message as 5 blocks, so you
  41.  will not be able to enter any from this block -4 if using fixed
  42.  ************************************************************************/
  43.     char last_msg_blk[7];                   // ascii, leading space
  44. /*****************************************************************
  45.  This is the maximum number of ACTIVE messages allowed, max is 999
  46.  *****************************************************************/
  47.     char msg_max[7];                        // ascii, leading space
  48.     byte reserved3[31];                // Zeroed
  49.     char node_max[2];                     // ascii, 1-36
  50.     };
  51.  
  52. /*************************************************************************
  53.  This is the BBS Node Record, it is stored in the second block of every
  54.  RBBS message file. For each additional RBBS node using this message base,
  55.  there will be a consecutive Node Record, up to 36.
  56.  *************************************************************************/
  57. struct node_record
  58.     {
  59.     char last_caller[31];
  60.     char sysop_avail_tog[2];          // Φ ASCII ("-1"=true, "0"=false)
  61.     char sysop_annoy_tog[2];                // Φ
  62.     char sysop_on_next_flag[2];             // Φ
  63.     char line_printer_avail_flag[2];        // Φ
  64.     char doors_avail_flag[2];               // Φ
  65.     char eight_bit_flag[2];                 // Φ
  66.     char callers_baud[2];                   // -1=300bps...-8=38400bps
  67.     char upper_case_only_flag[2];           // Φ
  68.     byte bytes_transferred[4];              // Long?
  69.     byte batch_transfer_flag;               // Non zero=TRUE
  70.     char graphics_setting[2];               // " 0"=none, " 1"=IBM, " 2"=ANSI
  71.     char sysop_flag[2];                     // Φ "-1" = sysop
  72.     char activity_flag;                     // 'A'=active, 'I'=inactive
  73.     char snoop_flag[2];                     // Φ
  74.     char rbbs_to_modem_baud[5];             // Ascii
  75.     byte caller_logon_time[3];              // Hour,Minute,Second
  76.     byte reserved1[4];
  77.     byte private_door_flag[2];              // Φ
  78.     byte type_of_shell;                     // 0=none,1=download,2=upload,3=ext regist pgm
  79.     char protocol_type;                     // First letter of protocol
  80.     byte reserved2;
  81.     byte last_dos_exit_date[2];             // Month, day, year (packed)
  82.     byte reserved3[7];
  83.     byte last_dos_exit_time[5];             // ascii HR:MN
  84.     char reliable_mode_flag[2];             // Φ
  85. /*****************************************************************
  86.  The following block usually contains the caller's city and state,
  87.  but is filled in whenever RBBS temporarily exits to dos.
  88.  *****************************************************************/
  89.     char pui_filename[8];
  90.     byte local_user_flag[2];         // (0x0D,0x0D)=Local
  91.     char local_user_mode[2];                // True=Com0
  92.     char current_conf_name[8];
  93.     word time_credits[2];            // Integer?
  94.     byte reserved4[2];
  95. /*****************************************************************/
  96.     byte last_subsystem[2];                 // Subsystem index where user was
  97.     char last_external_protocol_date[6];    // MMDDYY exited
  98.     char lasr_external_protocol_time[4];    // HHMM exited
  99.     };
  100.  
  101. /********************************************************************
  102.  Next we have the Message Header record. Each message starts with one
  103.  of these (17.4 allows multiple headers for 'carbon copy' to others).
  104.  RBBS does not remove old messages, only tags them, until you pack
  105.  the message base.
  106.  ********************************************************************/
  107. struct message_header
  108.     {
  109.     flag private_flag;                  // '*'=private, ' '=public
  110.     char msg_number[4];                     // In ascii, left justify
  111.     char from[31];                          // Uppercase
  112.     char to[22];                            // Uppercase
  113.     char time_sent[8];                      // HR:MN:SE
  114.     byte header_number;                    // Number of headers on this MSG,
  115.                                 //     1-225 (17.4)
  116.     char date_sent[8];                      // MN-DY-YR
  117.     char subject[25];                       // Uppercase
  118.     char password[15];                      // ^READ^ / ^KILL^
  119.     byte active;                             // 225=active, 226=killed
  120.     char msg_blk_size[4];                   // ascii, leading space
  121.     word read_sec_lev;                      // integer value
  122.     byte month,day,year;                  // Last Read, spaces if not
  123.     byte hour,minute,second;                // Last Read, spaces if not
  124.     };
  125.  
  126. /*************************************************************************
  127.  The last record used in the message base is simply a block of 128 bytes
  128.  that contains the actual message text. Instead of a CR/LF, each line is
  129.  terminated with an ascii 227 ('π'). Interestingly, this is the exact same
  130.  format used in a QWK mail packet. Multiple lines can be in one block and
  131.  lines can wrap over to the next. Number of block is stored in the Header.
  132.  *************************************************************************/
  133.  
  134. /******************************************************************
  135.  This is the format of the QWK message for either the QWK packet or
  136.  the REP. The only difference is the value of qwk.number
  137.  ******************************************************************/
  138. struct QWK
  139.     {
  140.     byte status_flag;       // ' ' in my findings
  141. /********************************************************************
  142.  If this is from the QWK packet this is the message number,
  143.  if its the REP, the conference number is here as well as in conf_num
  144.  ********************************************************************/
  145.     char number[7];         // in ascii, left justified
  146.     char date[8];           // mm-dd-yy (ascii)
  147.     char time[5];           // 24 hour hh:mm
  148.     char to[25];        // Uppercase, left justified
  149.     char from[25];        // ""
  150.     char subject[25];        // mixed case
  151.     char password[12];    // ^KILL^, ^READ^
  152.     char ref_msg_num[8];    // ascii, left j, blank filled
  153.     char msg_blk_size[6];   // in ascii + header (2 min), left J
  154.     byte active_flag;        // 225=active, 226=killed
  155.     word conf_num;        // integer value
  156.     byte reserved1[2];    // unused.
  157.     char network_flag;     // *=network tagline is present, ' ' otherwise
  158.     };
  159.  
  160. /*******************************************************************
  161.  From this point on are my proprietary structures to hold temp info
  162.  while accessing the message base and retrieving/building messages.
  163.  These ARE NOT rbbs formats, just intended to make life easier since
  164.  RBBS holds lot's of numbers in ASCII format (???).
  165.  *******************************************************************/
  166.  
  167. /******************************************
  168.  Check Point Record handy data structure
  169.  All these number are offset 1 in Real Life
  170.  ******************************************/
  171. typedef struct
  172.     {
  173.     long    last_msg_num;     // Last message Number            (offset 1)
  174.     long     first_msg_blk;    // Block # of first message       (offset 0)
  175.     long    last_msg_blk;     // Block # of last message        (offset 0)
  176.     long  next_msg_blk;     // Block where next message goes  (offset 0)
  177.     long    msg_max;          // Max Number of messages allowed (offset 1)
  178.     }CPR;
  179.  
  180. /****************************************************************
  181.  Here's my message format. Generic to convert from/to rbbs or qwk
  182.  ****************************************************************/
  183. typedef struct
  184.     {
  185.     byte hour;
  186.     byte minute;
  187.     byte second;
  188.     byte month;
  189.     byte day;
  190.     byte year;
  191.     }DTG;
  192.  
  193. typedef struct
  194.     {
  195.     word number;          // message number
  196.     char from[32];
  197.     char to[26];
  198.     char subject[26];
  199.     char password[16];
  200.     DTG sent;                    // When msg was sent
  201.     DTG read;                  // When msg was read
  202.     int  conf;          // Conference Number
  203.     int  level;               // Sec Lev to read
  204.     flag active;              // True or False
  205.     flag priv;                // True or false
  206.     char *text_buffer;      // pointer to the msg text
  207.     long size;          // number of text blocks+header
  208.     }MSG;
  209.  
  210. /*****************************************
  211.  Here are structures for linked lists used
  212.  when reading the host configuration file
  213.  *****************************************/
  214. struct ll_conf
  215.     {
  216.     int number;
  217.     int processed;
  218.     int last_read;
  219.     char path[81];
  220.     struct ll_conf *next;
  221.     };
  222.  
  223. struct ll_who
  224.     {
  225.     char user[32];
  226.     struct ll_who *next;
  227.     };
  228.  
  229. struct ll_swap
  230.     {
  231.     char from[32],to[32];
  232.     struct ll_swap *next;
  233.     };
  234.  
  235. /***************************************
  236.  This is the structure holding all the
  237.  data from  the host configuration file.
  238.  ***************************************/
  239. typedef struct
  240.     {
  241.     flag append;
  242.     flag killqwk;
  243.     flag pass_private;
  244.     char qwkname[81];
  245.     char repname[81];
  246.     char tagline[81];
  247.     char logfile[81];
  248.     char workdir[81];
  249.     char zip[81];
  250.     char unzip[81];
  251.     char hostname[9];
  252.     char lmrname[13];
  253.     struct ll_swap *import;
  254.     struct ll_swap *export;
  255.     struct ll_conf *conf;
  256.     struct ll_who *loser;
  257.     struct ll_who *exempt;
  258.     int conf_count;
  259.     int loser_count;
  260.     int exempt_count;
  261.     int msg_count;
  262.     }CONFIG;
  263.  
  264. /***************************
  265.  Last Message Read Structure
  266.  ***************************/
  267. struct LMR
  268.     {
  269.     int number;
  270.     int last_read;
  271.     };
  272.  
  273. /****************************
  274.  Simple text window structure
  275.  for direct screen writes
  276.  ****************************/
  277. typedef struct
  278.     {
  279.     int far *screen;
  280.     unsigned char x1;
  281.     unsigned char y1;
  282.     unsigned char x2;
  283.     unsigned char y2;
  284.     int border;
  285.     int text;
  286.     int header;
  287.     unsigned char cx;
  288.     unsigned char cy;
  289.     char title[80];
  290.     }WIN;
  291.  
  292. /*******************
  293.  Function Prototypes
  294.  *******************/
  295. void pos_qwk(FILE *infile);
  296. void pos_rbbs(FILE *infile);
  297. void read_rbbs_header(CPR *cpr, FILE *infile);
  298. void write_rbbs_header(CPR *cpr,FILE *outfile);
  299. int read_rbbs(MSG *msg,FILE *infile);
  300. int write_rbbs(MSG *msg,char *file);   //Notice this uses name vice handle
  301. int read_qwk(MSG *msg,FILE *infile);
  302. void write_qwk(MSG *msg,FILE *outfile);
  303. void failure(char *,...);
  304. void *e_malloc(size_t size);
  305. void show_msg(MSG *msg);
  306. void show_header(MSG *msg);
  307. void getblock(void *buff,long block,FILE *infile);
  308. void putblock(void *buff,long block,FILE *outfile);
  309. void addblock(void *buff,FILE *outfile);
  310. void addtag(MSG *msg);
  311. void padcpy(char *to, char *from,int length);
  312. void lpadcpy(char *to, char *from,int length);
  313. void termcpy(char *to, char *from,int length);
  314. void get_dtg(DTG *dtg);
  315. void padzcpy(char *to, char *from,int length);
  316. void remls(char *);
  317. void read_config(CONFIG *config, char *cfgfile);
  318. void openwin(WIN *win);
  319. void wallpaper(WIN *win);
  320. void scrollwin(WIN *win);
  321. void printwin(WIN *win, char *str);
  322. void printfwin(WIN *win, char *str,...);
  323. void make_lmr(void);
  324. void export(char *host);
  325. void import(char *host);
  326. int deny(MSG *msg);
  327. int exempt(MSG *msg);
  328. void checkworkdir(char *dir);
  329. void unzip(void);
  330. void zip(void);